<?php
/**
* 购物车模块Api Controller
*
* 购物车模块Api Controller的注意及说明
* 以下use模块请不要互相伤害
*
* @author    xiecz <xiecz@yunys.com.cn>
* @copyright 2016 QuanZhouYunYiShang Inc.
*/
namespace App\Http\Controllers\Api\Car;

use Illuminate\Routing\Controller as BaseController;
use Response,Request;
use App\Services\Car\Api;

class CarController extends BaseController{

    function __construct(Api $api){
        $this->api  = $api;
        $this->middleware('transaction',['only'=>['postAddShopCar',
                                                  'postCarSelect',
                                                  'postEditCarComplete',
                                                  'postDelShopCarCreate',
                                                  'postUpdShopCarCreate',
                                                  'postShopCarCheckAllOrCancelAll',
                                                  'shopCarCleanFromInvalid']]);
    }

    //添加购物车
    function postAddShoppingCar(){
        $input  = Request::all();
        $result = $this->api->addShopCar($input);
        return response()->json($result);
    }

    //购物车商品选中及未选中
    function postCarSelect(){
        $input  = Request::all();
        $result = $this->api->carSelect($input);
        return response()->json($result);
    }

    //清空失效商品
    function shopCarCleanFromInvalid(){
        $input  = Request::all();
        $result = $this->api->shopCarCleanFromInvalid($input);
        return response()->json($result);
    }

    //全选或全取消
    function postShopCarCheckAllOrCancelAll(){
        $input  = Request::all();
        $result = $this->api->shopCarCheckAllOrCancelAll($input);
        return response()->json($result);
    }

    //购物车列表
    function postShopCarList(){
        $input  = Request::all();
        $result = $this->api->shopCarList($input);
        return response()->json($result);
    }

    //编辑完成接口
    function postEditCarComplete(){
        $input  = Request::all();
        $result = $this->api->editCarComplete($input);
        return response()->json($result);
    }

    //购物车结算页
    function shopCarSubmit(){
        $input  = Request::all();
        $result = $this->api->shopCarSubmit($input);
        return response()->json($result);
    }

    //删除购物车中商品
    function deleteShopCar(){
        $input  = Request::all();
        $result = $this->api->delete_shop_car($input);
        return response()->json($result);
    }

    //修改购物车中商品数量
    function postUpdShopCarCreate(){
        $input  = Request::all();
        $result = $this->api->updShopCarCreate($input);
        return response()->json($result);
    }

    //立即购买结算接口
    function buyImmediatelySubmit(){
        $input  = Request::all();
        $result = $this->api->buyImmediatelySubmit($input);
        return response()->json($result);
    }



    function test(Request $request){
        $input  = $request->all();
        $result = $this->api->test($input);
        return $result;
    }
}